﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace oled
{
    public class Bit
    {
        public bool[] Big_endian; //正向,高位在前Big_endian
        public bool[] Little_endian; //逆向,低位在前Little_endian

        public Bit(Byte data)
        {
            Initialize(data);
        }
        private void Initialize(Byte data)
        {
            Big_endian = new bool[8];
            Little_endian = new bool[8];
            for (int i = 0; i < 8; i++)
            {
                bool bl = ((data & 0x01) == 1);

                Big_endian[7 - i] = bl;
                Little_endian[i] = bl;
                data = (Byte)(data >> 1);
            }
        }
        public static bool[] Bool_Array(Byte data, bool Algin_Mode)
        {
            int i = 0, loop = 8, inc = 1;
            bool[] Array = new bool[8];

            if (Algin_Mode == false)
            {
                i = 7;
                loop = 0;
                inc = -1;
            }

            for (; i < loop; i += inc)
            {
                bool bl = ((data & 0x01) == 1);
                Array[i] = bl;
                data = (Byte)(data >> 1);
            }
            return Array;
        }
    }
}
